package com.gec.controller;

import com.gec.dao.BookDao;
import com.gec.dao.BookDao1;
import com.gec.dao.BookDao2;
import com.gec.dao.BookDao3;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

/**

 - 处理删除客房的请求
 */
@WebServlet("/DeleteBookServlet")
public class DeleteBookServlet extends HttpServlet {
    /**
     - 根据客房的编号 去数据库中删除对应的客房信息
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //        DeleteBookServlet?id=${book.id}
        //获取用户的id

        String id = req.getParameter("id");
        //调用dao中的删除信息的方法
        BookDao bookDao = new BookDao();
        BookDao1 bookDao1 = new BookDao1();
        bookDao.deleteBook(id);
        bookDao1.deleteBook(id);
        BookDao2 bookDao2=new BookDao2();
        bookDao2.deleteBook(id);
        BookDao3 bookDao3=new BookDao3();
        bookDao3.deleteBook(id);
        //删除成功后 应该去客房列表页面
        resp.sendRedirect("BookListServlet");
    }
}

